import type { ClientCacheServiceResult } from "./ClientCache";

/**
 * 实例相关操作
 */
export const ClientInstanceService = (cache: ClientCacheServiceResult) => {
  return {
    /**
     * 获取状态信息，用于展示
     *
     * @param id 链接ID
     * @param url 链接
     */
    getState: async (id: string, url: string) => {
      const client = await cache.getClientCache(id);
      return client.getState(url);
    },

    /**
     * 集群健康状态
     */
    clusterHealth: async (id: string) => {
      const client = await cache.getClientCache(id);
      return client.clusterHealth();
    },

    /**
     * 获取节点基础信息
     */
    info: async (id: string) => {
      const client = await cache.getClientCache(id);
      return client.info();
    }
  };
};
